import { defineStore } from 'pinia';

export const useGitStore = defineStore('gitStore', {
  state: () => ({
    gitData: null,
  }),
  actions: {
    async fetchGitData(link: string) {
      try {
        const response = await fetch('/data', {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
          },
          body: JSON.stringify({ link }),
        });
        this.gitData = await response.json();
      } catch (error) {
        console.error('Error fetching git data:', error);
      }
    },
  },
});